package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.service.CheckGroupService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CheckGroupController {
    @Reference
    private CheckGroupService checkGroupService;

    // /checkgroup/add 新增页面
    @RequestMapping("/checkgroup/add")
    public Result add(Integer[] checkitemIds, @RequestBody  CheckGroup checkGroup){
        return checkGroupService.add(checkGroup,checkitemIds);
    }

    // /checkgroup/findPage  分页查询
    @RequestMapping("/checkgroup/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return checkGroupService.findPage(queryPageBean);

    }

    // /checkgroup/findById
    @RequestMapping("/checkgroup/findById")
    public Result findById(Integer id){
        return checkGroupService.findById(id);
    }

    // /checkgroup/findCheckItemIdsByCheckGroupId
    @RequestMapping("/checkgroup/findCheckItemIdsByCheckGroupId")
    public Result findCheckItemIdsByCheckGroupId(Integer id){
        return checkGroupService.findCheckItemIdsByCheckGroupId(id);
    }

    // /checkgroup/edit
    @RequestMapping("/checkgroup/edit")
    public Result edit(Integer []checkitemIds,@RequestBody CheckGroup checkGroup){
        return checkGroupService.addCheckGroupIdAndCheckItem(checkGroup,checkitemIds);
    }

    // /checkgroup/findAll
    @RequestMapping("/checkgroup/findAll")
    public Result findAll(){
        return checkGroupService.findPageAll();
    }

    // /checkgroup/delete  id

    @RequestMapping("/checkgroup/delete")
    public Result delete(Integer id){
        return checkGroupService.delete(id);
    }


}
